﻿Partial Public Class ViewExplorer
    Private Sub ExportToCSV(ByVal sender As Object, ByVal e As EventArgs)

        'OutStandingIssue: On ne peut pas exporter la vue detail seulement... Il faut passerpar la Vue principal.
        'Work Around: Reconstruire une grille avec la table dataSet via le FocusedView.Tag.ToString (Comme ContextMenuVEdit) et appliquer un filtre apartir du la Row Parent.
        'aleblanc - 2011-07-26
        'http://www.devexpress.com/Support/Center/p/S130097.aspx.  C'est pareil pour les XLS
        '
        Dim filename As String
        Try
            filename = IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), aGridControl.GridView1.Tag.ToString + ".csv")
            Dim options As New XtraPrinting.CsvExportOptions() With {.QuoteStringsWithSeparators = True, .Separator = " ", .TextExportMode = TextExportMode.Text}
            aGridControl.GridView1.OptionsPrint.AutoWidth = False
            aGridControl.GridView1.OptionsPrint.PrintDetails = True
            aGridControl.GridView1.OptionsPrint.ExpandAllDetails = True
            aGridControl.GridView1.OptionsPrint.ExpandAllGroups = True
            aGridControl.GridView1.ExportToCsv(filename, options)

            MessageWindow.ShowMessage(String.Format("Export To CSV File Succesfull.{0}{0}Your Filename is: {1}", vbCrLf, filename), MsgBoxStyle.Information)

        Catch ex As Exception
            Throw ex
        End Try
        Me.Cursor = Cursors.Default
    End Sub
End Class
